﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace PicSolve
{
    public static class PicHelper
    {
        public static PLine MergeLinePattern(PLine pl1, PLine pl2)
        {
            int length = pl1.Length;
            if (length != pl2.Length)
            {
                throw new InvalidOperationException("Deux lignes sont de tailles différentes");
            }

            PLine res = new PLine(length); ;

            for (int i = 0; i < length; i++)
            {
                switch ((int)pl1[i] + (int)pl2[i])
                {
                    case 0:
                        res[i] = PValue.Unknown;
                        break;
                    case 1:
                        res[i] = PValue.Unknown;
                        break;
                    case 2:
                        res[i] = PValue.NoBox;
                        break;
                    case 3:
                        res[i] = PValue.Unknown;
                        break;
                    case 4:
                        throw new InvalidOperationException("Les deux lignes sont incompatibles");
                    case 6:
                        res[i] = PValue.Box;
                        break;
                    default:
                        break;
                }
            }

            return res;
        }
    }
}
